<template>
  <div class="app-box">
    <Layout ref="runBox"
            title="拖车信息查询"
            temp="manual-vehicle-manager"
            @handleSuccessMqttMessage="handleSuccessMqttMessage"
            @refreshMenus="refreshMenus"
            :ic="ic"
            :url="url"
            :custom="custom"
            :closeReadCard="false"
            :readID="false"
            :readIC="false"></Layout>
  </div>
</template> 
<script>
import Layout from '../core/layout.vue'
import { GSAConstants } from '@/utils/access'
import {
  log,
} from '@/utils/message'
export default {
  components: { Layout },
  watch: {
    "$store.state.user.menus": {
      handler: function (newValue) {
        this.refreshMenus()
      }
    }
  },
  data () {
    return {
      custom: {
        saveExcelDisable: true
      },
      ic: GSAConstants().TOPIC_QUERY_ID_NOTICE.ic,
      url: GSAConstants().TOPIC_QUERY_ID_NOTICE.url
    }
  },
  created () {
    this.refreshMenus()
  },
  mounted () {

  },
  methods: {
    // 刷新菜单权限
    refreshMenus () {
      const menus = this.$store.getters.menus
      log('OSD 刷新权限', menus)

      // CMSSSD_Export（⾮⾃动出⻜⻋辆导出）
      this.custom.saveExcelDisable = true
      menus.forEach(menu => {
        const rightId = menu.key.rightId.trim()
        if (rightId === 'CMSSSD_Export') {
          this.custom.saveExcelDisable = false
        }
      })
    },
    showMsg (msg, type) {
      this.$refs.runBox.showMsg(msg, type)
      // osd 
      // CMSOSD_Update（修改）
      // CMSOSD_ Nullify（作废）
      // CMSOSD_ Reprint（重印CMS）
      // CMSOSD_ Export（导出） 
    },
    // 读卡成功的回调信息  
    handleSuccessMqttMessage (messageObject) {
      log('handleSuccessMqttMessage 开始处理业务', messageObject, ', current IC', this.ic)
      if (messageObject.ic === this.ic) {
        this.showMsg('处理成功', 'green')
      }
    }
  },
}
</script>

<style scoped>
.app-box {
  padding: 0px;
}
</style>
